<template>
    <div id="equipmentDraw" class="equipment-draw">
        <h3 class="dialog-plate-title"><span>设备图纸</span></h3>
        <!-- 树菜单 -->
        <div class="block" ref="tree" style="margin-top: 10px;overflow-y: auto;">
            <el-tree :data="dataList" node-key="id" :props="defaultProps" :expand-on-click-node="false" accordion>
                 <span class="custom-tree-node" slot-scope="{ node, data }">
                    <span @click="openTableDialog(data)"
                          style="font-size: 15px;font-weight: bold;">{{ node.label }}</span>
                     <!--<span>-->
                     <!--<el-button circle icon="el-icon-menu" size="mini" type="success"></el-button>-->
                     <!--<el-button circle icon="el-icon-plus" size="mini" type="success" @click="append(node,data)"></el-button>-->
                     <!--<el-button circle icon="el-icon-edit" size="mini" type="primary" @click="edit(node, data)"></el-button>-->
                     <!--<el-button circle icon="el-icon-delete" size="mini" type="warning" @click="remove(node, data)"></el-button>-->
                     <!--</span>-->
                  </span>
            </el-tree>
        </div>

        <!-- 表格dialog -->
        <el-dialog :title="dialogTableTitle" width="90%" top="30px" class="table-dialog" :visible.sync="isTableDialog"
                   :close-on-click-modal="false">
            <el-tabs v-model="activeName" @tab-click="handleDialogClick">
                <el-tab-pane label="基本信息" name="1" :style="tableDialogHeightTabPane">
                    <!-- 基本信息列表-->
                    <h3 class="dialog-plate-title"><span>基本信息</span></h3>
                    <el-form :inline="true" class="demo-form-inline" label-position="right" label-width="150px"
                             :model="tableDialogData.essentialInfo">
                        <el-form-item label="图纸名称">
                            <el-input v-model="tableDialogData.essentialInfo.drawingName"></el-input>
                        </el-form-item>
                        <el-form-item label="图纸图号">
                            <el-input v-model="tableDialogData.essentialInfo.drawingCode"></el-input>
                        </el-form-item>
                        <el-form-item label="版本号">
                            <el-input v-model="tableDialogData.essentialInfo.drawingVersion"></el-input>
                        </el-form-item>
                        <el-form-item label="图纸类型">
                            <el-input v-model="tableDialogData.essentialInfo.drawingType_desc" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="图纸创建人">
                            <el-input v-model="tableDialogData.essentialInfo.drawingCreater_name" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="创建时间">
                            <el-input v-model="tableDialogData.essentialInfo.createTime" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="最后修改时间">
                            <el-input v-model="tableDialogData.essentialInfo.lastEditTime" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="修订次数">
                            <el-input v-model="tableDialogData.essentialInfo.changeTimes" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="价格">
                            <el-input v-model="tableDialogData.essentialInfo.drawingPrice" type="number"></el-input>
                        </el-form-item>
                        <el-form-item label="相关部门">
                            <el-select v-model="tableDialogData.essentialInfo.relevantDept" multiple placeholder="请选择"
                                       style="width: 200px;">
                                <el-option
                                        v-for="item in departments"
                                        :key="item.id"
                                        :label="item.deptName"
                                        :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="是否需要培训">
                            <el-select v-model="tableDialogData.essentialInfo.drawingNeedTrain" style="width: 200px;">
                                <el-option label="否" value="0"></el-option>
                                <el-option label="是" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="图纸发布人">
                            <el-input v-model="tableDialogData.essentialInfo.drawingPublisher_name" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="图纸发布时间">
                            <el-input v-model="tableDialogData.essentialInfo.drawingPublishTime" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="图纸是否发布">
                            <el-select v-model="tableDialogData.essentialInfo.drawingIsPublish" disabled
                                       style="width: 200px;">
                                <el-option label="否" value="0"></el-option>
                                <el-option label="是" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-form>
                    <el-form label-position="right" label-width="150px" :model="tableDialogData.essentialInfo">
                        <el-form-item label="备注">
                            <el-input v-model="tableDialogData.essentialInfo.drawingRemark" type="textarea"></el-input>
                        </el-form-item>
                    </el-form>
                    <el-form label-position="right" label-width="150px" :model="tableDialogData.essentialInfo">
                        <el-form-item label="工艺说明">
                            <quill-editor v-model="tableDialogData.essentialInfo.technicsRemark"
                                          style="padding-right: 10px;"></quill-editor>
                        </el-form-item>
                    </el-form>
                    <!-- 申请修改单记录-->
                    <div>
                        <h3 class="dialog-plate-title" style="margin-top: 15px;"><span>记录</span></h3>
                        <el-tabs v-model="activeTableName" @tab-click="handleRecordDialogClick"
                                 style="width: 99%;height: 500px;">
                            <el-tab-pane label="申请修改记录" name="first">
                                <el-button v-if="jurisdiction.insertDrawingEditInfo" type="primary" icon="el-icon-plus"
                                           size="mini" @click="AddApplyDialog">
                                    新增申请修改
                                </el-button>
                                <el-table
                                        :data="applyData.slice((currentPage-1)*pagesize,currentPage*pagesize)"
                                        stripe
                                        border
                                        class="apply-table"
                                        height="500"
                                        style="width: 100%;"
                                        :header-cell-style="getRowClass"
                                >
                                    <el-table-column fixed type="index" label="*" sortable width="40"></el-table-column>
                                    <el-table-column prop="modifierName" label="申请人" sortable
                                                     width="100"></el-table-column>
                                    <el-table-column prop="modifyTime" label="申请时间" :formatter="formatTimestampToTime"
                                                     sortable width="170"></el-table-column>
                                    <el-table-column prop="modifyReason" label="申请原因" sortable
                                                     width="450"></el-table-column>
                                    <el-table-column prop="approvalResult" label="状态" :formatter="formatResult" sortable
                                                     width="110"></el-table-column>
                                    <el-table-column prop="approvalPersonName" label="发布人" sortable
                                                     width="100"></el-table-column>
                                    <el-table-column prop="approvalTime" label="发布时间" :formatter="formatTimestampToTime"
                                                     sortable width="170"></el-table-column>
                                    <el-table-column prop="drawingNeedTrain" label="是否需要培训" :formatter="formatNeedTrain"
                                                     sortable width="250"></el-table-column>
                                    <el-table-column fixed="right" label="操作" sortable align="center" width="120">
                                        <template slot-scope="scope">
                                            <span v-if="jurisdiction.releaseEditInfo">
                                                 <el-button v-if="scope.row.approvalResult == '3'"
                                                            @click="goRelease(scope.row)" type="text"
                                                            size="small">发布</el-button>
                                            </span>
                                            <el-button @click="editApplyDialog(scope.row)" type="text" size="small">{{
                                                scope.row.approvalResult == '5' ? "查看" : "审核" }}
                                            </el-button>
                                        </template>
                                    </el-table-column>
                                </el-table>
                                <el-pagination
                                        background
                                        @size-change="handleSizeChange"
                                        @current-change="handleCurrentChange"
                                        :current-page="currentPage"
                                        :page-sizes="[5,10, 15,20, 25, 30 ,50, 100]"
                                        :page-size="pagesize"
                                        layout="total, sizes, prev, pager, next, jumper"
                                        :total="applyData.length">
                                </el-pagination>
                            </el-tab-pane>
                            <el-tab-pane label="回收与发放记录" name="second">
                                <el-button v-if="jurisdiction.insertIssueRecovery" @click="addGrant" type="primary"
                                           icon="el-icon-plus" size="mini">新增发放
                                </el-button>
                                <el-table
                                        :data="tableGrantRecoveryData.slice((currentPage-1)*pagesize,currentPage*pagesize)"
                                        stripe border class="user-table" height="500" style="width: 100%;"
                                        :header-cell-style="getRowClass">
                                    <el-table-column fixed type="index" label="*" sortable width="40"></el-table-column>
                                    <el-table-column prop="drawingVersion" label="版本号" sortable
                                                     width="120"></el-table-column>
                                    <el-table-column prop="issuerName" label="发放人" sortable
                                                     width="100"></el-table-column>
                                    <el-table-column prop="issuNum" label="发放数量" sortable width="110"></el-table-column>
                                    <el-table-column prop="receiverName" label="接收人" sortable
                                                     width="100"></el-table-column>
                                    <el-table-column prop="receiveTime" label="接收时间" :formatter="formatTimestampToTime"
                                                     sortable width="170"></el-table-column>
                                    <el-table-column prop="issuRemark" label="发放备注" sortable
                                                     width="300"></el-table-column>
                                    <el-table-column prop="recoverierName" label="回收人" sortable
                                                     width="100"></el-table-column>
                                    <el-table-column prop="recoveryTime" label="回收时间" :formatter="formatTimestampToTime"
                                                     sortable width="170"></el-table-column>
                                    <el-table-column prop="recoveryRemark" label="回收备注" sortable
                                                     width="350"></el-table-column>
                                    <el-table-column fixed="right" label="操作" sortable align="right" width="80">
                                        <template slot-scope="scope">
                                            <el-button @click="goRecovery(scope.row)" type="text" size="small">{{
                                                scope.row.recoverierName ? "查看":"回收"}}
                                            </el-button>
                                        </template>
                                    </el-table-column>
                                </el-table>
                                <el-pagination background @size-change="handleSizeChange"
                                               @current-change="handleCurrentChange" :current-page="currentPage"
                                               :page-sizes="[5,10, 15,20, 25, 30 ,50, 100]" :page-size="pagesize"
                                               layout="total, sizes, prev, pager, next, jumper"
                                               :total="tableGrantRecoveryData.length"></el-pagination>
                            </el-tab-pane>
                            <el-tab-pane label="培训记录" name="third">
                                <el-table :data="tableTrainData.slice((currentPage-1)*pagesize,currentPage*pagesize)"
                                          stripe border class="user-table" height="500" style="width: 100%;"
                                          :header-cell-style="getRowClass">
                                    <el-table-column fixed type="index" label="*" sortable width="40"></el-table-column>
                                    <el-table-column prop="drawingVersion" label="版本号" sortable
                                                     width="180"></el-table-column>
                                    <el-table-column prop="trainHostName" label="培训主持人" sortable
                                                     width="130"></el-table-column>
                                    <el-table-column prop="trainTime" label="培训时间" :formatter="formatTimestampToTime"
                                                     sortable width="170"></el-table-column>
                                    <el-table-column prop="trainJoinor" label="培训参与人" sortable
                                                     width="1100"></el-table-column>
                                    <el-table-column fixed="right" label="操作" sortable align="right" width="80">
                                        <template slot-scope="scope">
                                            <el-button @click="updateTrain(scope.row)" type="text" size="small">{{
                                                scope.row.trainHostName ? "查看" : "修改"}}
                                            </el-button>
                                        </template>
                                    </el-table-column>
                                </el-table>
                                <el-pagination background @size-change="handleSizeChange"
                                               @current-change="handleCurrentChange" :current-page="currentPage"
                                               :page-sizes="[5,10, 15,20, 25, 30 ,50, 100]" :page-size="pagesize"
                                               layout="total, sizes, prev, pager, next, jumper"
                                               :total="tableTrainData.length"></el-pagination>
                            </el-tab-pane>
                        </el-tabs>
                    </div>
                </el-tab-pane>
                <el-tab-pane label="设备图纸信息" name="2" :style="tableDialogHeightTabPane">
                    <div style="overflow: hidden;margin-bottom: 20px;">
                        <el-upload class="upload-demo"
                                   style="width: 99%;margin: 0 auto;"
                                   ref="uploadDraw"
                                   action="/api/adscm/zltx/jyDrawingList/uploadDrawing/1"
                                   :auto-upload="false"
                                   :on-success="uploadDrawSuccess"
                                   :on-error="uploadDrawError"
                                   :limit="1"
                        >
                            <el-button slot="trigger" size="small" type="primary">上传图纸文件</el-button>
                        </el-upload>
                    </div>
                    <div style="overflow: hidden;">
                        <div style="width: 99%;margin: 0 auto;">
                            <el-input v-model.number="drawingPage" type="number" style="width: 150px;" min="1"
                                      :max="drawingNumPages"></el-input>
                            <span>/{{drawingNumPages}}</span>
                            <el-button @click="drawingRotate += 90">&#x27F3;</el-button>
                            <el-button v-if="jurisdiction.printDrawingPdf" @click="$refs.drawingPdf.print()">打印</el-button>
                            <el-button v-if="jurisdiction.downloadPdf" @click="downloadAppendix('table','tableNow')">下载</el-button>
                            <pdf ref="drawingPdf"
                                 style="border: 1px solid red;"
                                 :src="tableDialogData.drawingSrc"
                                 :page="drawingPage"
                                 :rotate="drawingRotate"
                                 @progress="drawingLoadedRatio = $event"
                                 @num-pages="drawingNumPages = $event"
                                 @link-clicked="drawingPage = $event">
                            </pdf>
                        </div>
                    </div>
                </el-tab-pane>
                <el-tab-pane label="附件信息" name="3" :style="tableDialogHeightTabPane">
                    <div style="overflow: hidden;margin-bottom: 20px;">
                        <el-upload class="upload-demo"
                                   style="width: 99%;margin: 0 auto;"
                                   ref="uploadAppendix"
                                   :action="appendixUrl"
                                   :auto-upload="false"
                                   :on-success="uploadAppendixSuccess"
                                   :on-error="uploadAppendixError"
                        >
                            <el-button slot="trigger" size="small" type="primary">上传附件</el-button>
                        </el-upload>
                    </div>
                    <ul style="padding: 5px 0;">
                        <li v-for="(item,index) in tableDialogData.essentialInfo.annexes"
                            style="overflow: hidden;padding: 3px;border-bottom: 1px solid #ececec;">
                            <span style="float:left;">{{item.annexName}}</span>
                            <el-button type="primary" size="mini" @click="downloadAppendix(item.id,'applyAppenddix')"
                                       style="float:right;">下载
                            </el-button>
                        </li>
                    </ul>
                </el-tab-pane>
            </el-tabs>
            <div slot="footer" class="dialog-footer" style="overflow: hidden;">
                <div v-if="jurisdiction.updateDrawingList">
                    <el-button v-if="tableDialogData.essentialInfo.addFlag == '0'" type="primary" style="float: right;"
                               @click="submitUpload">确 定
                    </el-button>
                </div>
            </div>
        </el-dialog>

        <!-- 申请记录dialog -->
        <el-dialog :title="dialogApplyTitle" width="80%" top="30px" class="apply-dialog" :visible.sync="isApplyDialog"
                   :close-on-click-modal="false">
            <el-tabs v-model="activeApplyName" @tab-click="handleApplyDialogClick">
                <el-tab-pane label="申请基本信息" name="1" :style="tableDialogHeightTabPane">
                    <!-- 基本信息列表-->
                    <el-form :inline="true" class="demo-form-inline" label-position="right" label-width="150px"
                             :model="applyDialogData.essentialInfo">
                        <el-form-item label="申请人">
                            <el-input v-model="applyDialogData.essentialInfo.modifierName" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="申请时间">
                            <el-input v-model="applyDialogData.essentialInfo.modifyTime" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="图纸名称">
                            <el-input v-model="applyDialogData.essentialInfo.drawingName"
                                      :disabled="dialogApplyTitle === '审核申请'"></el-input>
                        </el-form-item>
                        <el-form-item label="图纸图号">
                            <el-input v-model="applyDialogData.essentialInfo.drawingCode"
                                      :disabled="dialogApplyTitle === '审核申请'"></el-input>
                        </el-form-item>
                        <el-form-item label="版本号">
                            <el-input v-model="applyDialogData.essentialInfo.drawingVersion"
                                      :disabled="dialogApplyTitle === '审核申请'"></el-input>
                        </el-form-item>
                        <el-form-item label="价格">
                            <el-input v-model="applyDialogData.essentialInfo.drawingPrice"
                                      :disabled="dialogApplyTitle === '审核申请'"></el-input>
                        </el-form-item>
                        <el-form-item label="相关部门">
                            <el-select v-model="applyDialogData.essentialInfo.relevantDept"
                                       :disabled="dialogApplyTitle === '审核申请'" multiple placeholder="请选择"
                                       style="width: 200px;">
                                <el-option
                                        v-for="item in departments"
                                        :key="item.id"
                                        :label="item.deptName"
                                        :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="是否需要培训">
                            <el-select v-model="applyDialogData.essentialInfo.drawingNeedTrain"
                                       :disabled="dialogApplyTitle === '审核申请'" style="width: 200px;">
                                <el-option label="否" value="0"></el-option>
                                <el-option label="是" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-form>
                    <el-form label-position="right" label-width="150px" :model="applyDialogData.essentialInfo">
                        <el-form-item label="备注">
                            <el-input v-model="applyDialogData.essentialInfo.drawingRemark" type="textarea"
                                      :disabled="dialogApplyTitle === '审核申请'"></el-input>
                        </el-form-item>
                    </el-form>
                    <el-form label-position="right" label-width="150px" :model="applyDialogData.essentialInfo">
                        <el-form-item label="工艺说明">
                            <quill-editor v-model="applyDialogData.essentialInfo.technicsRemark"
                                          @focus="dialogApplyTitle === '审核申请' ? onEditorFocus($event) : ''"
                                          style="padding-right: 10px;"></quill-editor>
                        </el-form-item>
                    </el-form>
                    <el-form label-position="right" label-width="150px" :model="applyDialogData.essentialInfo">
                        <el-form-item label="申请原因">
                            <el-input v-model="applyDialogData.essentialInfo.modifyReason" type="textarea"
                                      :disabled="dialogApplyTitle === '审核申请'"></el-input>
                        </el-form-item>
                    </el-form>
                    <el-form label-position="right" label-width="150px" :model="applyDialogData.essentialInfo">
                        <el-form-item label="修改内容">
                            <el-input v-model="applyDialogData.essentialInfo.modifyContent" type="textarea"
                                      :disabled="dialogApplyTitle === '审核申请'"></el-input>
                        </el-form-item>
                    </el-form>
                    <el-form v-if="dialogApplyTitle !== '新增申请'" :inline="true" class="demo-form-inline"
                             label-position="right" label-width="150px" :model="applyDialogData.essentialInfo">
                        <el-form-item label="图纸发布人">
                            <el-input v-model="applyDialogData.essentialInfo.drawingPublisher_name" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="图纸发布时间">
                            <el-input v-model="applyDialogData.essentialInfo.drawingPublishTime" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="图纸是否发布">
                            <el-select v-model="applyDialogData.essentialInfo.drawingIsPublish" disabled
                                       style="width: 200px;">
                                <el-option label="否" value="0"></el-option>
                                <el-option label="是" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-form>

                    <!-- 审核部门列表 -->
                    <div v-if="dialogApplyTitle !== '新增申请'">
                        <h3 class="dialog-plate-title" style="margin: 10px 0;"><span>审核部门列表</span></h3>
                        <el-table :data="applyDialogData.essentialInfo.auditings" stripe border height="300px"
                                  class="user-table" style="width: 100%;" :header-cell-style="getRowClass">
                            <el-table-column fixed type="index" label="*" sortable width="40"></el-table-column>
                            <el-table-column prop="auditingDeptName" label="审核部门" sortable
                                             width="160"></el-table-column>
                            <el-table-column prop="auditorName" label="审核人" :formatter="formatIsNull" sortable
                                             width="110"></el-table-column>
                            <el-table-column prop="aduditingDate" label="审核时间" :formatter="formatTimestampToTime"
                                             sortable width="170"></el-table-column>
                            <el-table-column prop="auditingResult" label="审核结果" :formatter="formatIsResult" sortable
                                             width="110"></el-table-column>
                            <el-table-column prop="auditingRemark" label="审核意见" :formatter="formatIsNull" sortable
                                             width="750"></el-table-column>
                            <el-table-column fixed="right" label="操作" sortable align="right" width="80">
                                <template slot-scope="scope">
                                    <el-button v-if=" scope.row.auditingResult != 1 " @click="goExamine(scope.row)"
                                               type="text" size="small">审核
                                    </el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                        <!-- 审核操作 -->
                        <h3 v-if="isSubmitExamine" class="dialog-plate-title" style="margin: 20px 0 10px;">
                            <span>审核操作</span></h3>
                        <div v-if="isSubmitExamine" style="padding-bottom: 20px;">
                            <el-form :inline="true" class="demo-form-inline" label-position="right" label-width="110px"
                                     :model="applyExamineList">
                                <el-form-item label="审核人">
                                    <el-input v-model="applyExamineList.auditorName" disabled></el-input>
                                </el-form-item>
                                <el-form-item label="审核时间">
                                    <el-input v-model="applyExamineList.aduditingDate" disabled></el-input>
                                </el-form-item>
                                <el-form-item label="审核部门">
                                    <el-input v-model="applyExamineList.auditingDeptName" disabled></el-input>
                                </el-form-item>
                                <el-form-item label="审核结果">
                                    <el-select v-model="applyExamineList.auditingResult" :disabled="isGoExamineButton">
                                        <el-option label="不通过" value="0"></el-option>
                                        <el-option label="通过" value="1"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-form>
                            <el-form label-position="right" label-width="110px" :model="applyExamineList">
                                <el-form-item label="审核意见">
                                    <el-input v-model="applyExamineList.auditingRemark" :disabled="isGoExamineButton"
                                              type="textarea"></el-input>
                                </el-form-item>
                            </el-form>
                            <div v-if="jurisdiction.auditingEditInfo" style="text-align: right;">
                                <el-button v-if="!isGoExamineButton" @click="submitExamine" type="primary">提交审核
                                </el-button>
                            </div>
                        </div>
                    </div>

                </el-tab-pane>
                <el-tab-pane label="申请图纸信息" name="2" :style="tableDialogHeightTabPane">
                    <!-- 上传pdf按钮 -->
                    <div v-if="dialogApplyTitle !== '审核申请'" style="overflow: hidden;margin-bottom: 20px;">
                        <el-upload class="upload-demo"
                                   style="width: 99%;margin: 0 .5%;float: left;"
                                   ref="uploadApplyDraw"
                                   action="/api/adscm/zltx/jyDrawingList/uploadDrawing/2"
                                   :auto-upload="false"
                                   :on-success="uploadDrawApplySuccess"
                                   :limit="1"
                        >
                            <el-button slot="trigger" size="small" type="primary">上传图纸文件</el-button>
                        </el-upload>
                    </div>
                    <div style="overflow: hidden;" v-if="dialogApplyTitle === '审核申请'">
                        <!-- 上一个版本 审核申请时不显示 -->
                        <div v-if="dialogApplyTitle === '审核申请'" style="width: 49%;margin: 0 .5%;float: left;">
                            <h3 class="dialog-plate-title" style="margin: 0 0 10px;"><span>上个版本</span></h3>
                            <el-input v-model.number="instructionsPageApply" type="number" style="width: 100px;" min="1"
                                      :max="instructionsNumPagesApply"></el-input>
                            <span>/{{instructionsNumPagesApply}}</span>
                            <el-button @click="instructionsRotateApply += 90">&#x27F3;</el-button>
                            <el-button v-if="jurisdiction.printDrawingPdf" @click="$refs.applyInstructionsPdf.print()">打印</el-button>
                            <el-button v-if="jurisdiction.downloadLastPdf"
                                       @click="downloadAppendix('last','applyLast')">下载
                            </el-button>
                            <pdf ref="applyInstructionsPdf"
                                 style="border: 1px solid red;"
                                 :src="applyDialogData.instructionsSrc"
                                 :page="instructionsPageApply"
                                 :rotate="instructionsRotateApply"
                                 @progress="instructionsLoadedRatioApply = $event"
                                 @num-pages="instructionsNumPagesApply = $event"
                                 @link-clicked="instructionsPageApply = $event">
                            </pdf>
                        </div>
                        <!-- 当前版本 -->
                        <div style="width: 49%;margin: 0 .5%;float: left;">
                            <h3 class="dialog-plate-title" style="margin: 0 0 10px;"><span>当前版本</span></h3>
                            <el-input v-model.number="drawingPageApply" type="number" style="width: 100px;" min="1"
                                      :max="drawingNumPagesApply"></el-input>
                            <span>/{{drawingNumPagesApply}}</span>
                            <el-button @click="drawingRotateApply += 90">&#x27F3;</el-button>
                            <el-button v-if="jurisdiction.printDrawingPdf" @click="$refs.applyDrawPdf.print()">打印</el-button>
                            <el-button v-if="jurisdiction.downloadPdf" @click="downloadAppendix('now','applyNow')">下载
                            </el-button>
                            <pdf ref="applyDrawPdf"
                                 style="border: 1px solid red;"
                                 :src="applyDialogData.drawingSrc"
                                 :page="drawingPageApply"
                                 :rotate="drawingRotateApply"
                                 @progress="drawingLoadedRatioApply = $event"
                                 @num-pages="drawingNumPagesApply = $event"
                                 @link-clicked="drawingPageApply = $event">
                            </pdf>
                        </div>
                    </div>
                </el-tab-pane>
                <el-tab-pane label="申请附件信息" name="3" :style="tableDialogHeightTabPane">
                    <!-- 附件上传按钮 -->
                    <div v-if="dialogApplyTitle !== '审核申请'" style="overflow: hidden;margin-bottom: 20px;">
                        <el-upload class="upload-demo"
                                   style="width: 99%;margin: 0 auto;"
                                   ref="uploadApplyAppendix"
                                   :action="applyAppendixUrl"
                                   :auto-upload="false"
                                   :on-success="uploadApplyAppendixSuccess"
                        >
                            <el-button slot="trigger" size="small" type="primary">上传附件</el-button>
                        </el-upload>
                    </div>
                    <!-- 附件列表 -->
                    <ul style="padding: 5px 0;">
                        <li v-for="(item,index) in applyDialogData.essentialInfo.annexes"
                            style="overflow: hidden;padding: 3px;border-bottom: 1px solid #ececec;">
                            <span style="float:left;">{{item.annexName}}</span>
                            <el-button v-if="jurisdiction.downloadAnnex" type="primary" size="mini"
                                       @click="downloadAppendix(item.id,'applyAppenddix')"
                                       style="float:right;">下载
                            </el-button>
                        </li>
                    </ul>
                </el-tab-pane>
            </el-tabs>
            <div slot="footer" class="dialog-footer">
                <el-button v-if="dialogApplyTitle === '新增申请'" type="primary" @click="submitApplyUpload">确 定</el-button>
            </div>
        </el-dialog>

        <!-- 发放与回收 -->
        <el-dialog :title="dialogGrantRecoveryTitle" width="700px" class="GrantRecovery-dialog"
                   :visible.sync="isGrantRecoveryDialog" :close-on-click-modal="false">
            <el-form :inline="true" class="demo-form-inline" label-position="right" label-width="110px"
                     :model="dialogGrantRecoveryList">
                <el-form-item label="发放人">
                    <el-input v-model="dialogGrantRecoveryList.issuerName" disabled></el-input>
                </el-form-item>
                <el-form-item label="接收时间">
                    <el-input v-model="dialogGrantRecoveryList.receiveTime" disabled></el-input>
                </el-form-item>
                <el-form-item label="发放版本">
                    <el-input v-model="dialogGrantRecoveryList.drawingVersion" disabled></el-input>
                </el-form-item>
                <el-form-item label="发放数量">
                    <el-input type="number" v-model="dialogGrantRecoveryList.issuNum"
                              :disabled="dialogGrantRecoveryTitle !== '发放'"></el-input>
                </el-form-item>
                <el-form-item label="接收人">
                    <el-select v-model="dialogGrantRecoveryList.receiver" :disabled="dialogGrantRecoveryTitle !== '发放'"
                               style="width: 200px;">
                        <el-option
                                v-for="item in allUserList"
                                :key="item.id"
                                :label="item.name"
                                :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item v-if="dialogGrantRecoveryTitle !== '发放'" label="回收人">
                    <el-input v-model="dialogGrantRecoveryList.recoverierName" disabled></el-input>
                </el-form-item>
                <el-form-item v-if="dialogGrantRecoveryTitle !== '发放'" label="回收时间">
                    <el-input v-model="dialogGrantRecoveryList.recoveryTime" disabled></el-input>
                </el-form-item>
            </el-form>
            <el-form label-position="right" label-width="110px" :model="dialogGrantRecoveryList">
                <el-form-item label="发放备注">
                    <el-input v-model="dialogGrantRecoveryList.issuRemark" :disabled="dialogGrantRecoveryTitle !== '发放'"
                              type="textarea"></el-input>
                </el-form-item>
            </el-form>
            <el-form v-if="dialogGrantRecoveryTitle !== '发放'" label-position="right" label-width="110px"
                     :model="dialogGrantRecoveryList">
                <el-form-item label="回收备注">
                    <el-input v-model="dialogGrantRecoveryList.recoveryRemark" type="textarea"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <div v-if="jurisdiction.recoveryDrawing">
                    <el-button v-if="!dialogGrantRecoveryList.recoverierName" @click="submitRecovery"
                               :disabled="!isDialogGrantRecoveryButton" type="primary">确 定
                    </el-button>
                </div>
            </div>
        </el-dialog>


        <!-- 培训 -->
        <el-dialog title="编辑" width="600px" class="GrantRecovery-dialog" :visible.sync="isTrainDialog"
                   :close-on-click-modal="false">
            <el-form label-position="right" label-width="110px" :model="dialogTrainList">
                <el-form-item label="版本号">
                    <el-input v-model="dialogTrainList.drawingVersion" disabled></el-input>
                </el-form-item>
                <el-form-item label="培训主持人">
                    <el-input v-model="dialogTrainList.trainHostName" disabled></el-input>
                </el-form-item>
                <el-form-item label="培训时间">
                    <el-date-picker v-model="dialogTrainList.trainTime" format="yyyy-MM-dd HH:mm:ss" type="datetime"
                                    placeholder="选择日期时间"></el-date-picker>
                </el-form-item>
                <el-form-item label="培训参与人员">
                    <el-input v-model="dialogTrainList.trainJoinor" type="textarea"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <div v-if="jurisdiction.updateDrawingTrain">
                    <el-button v-if="!dialogTrainList.trainHostName" @click="submitTrain" type="primary"
                               :disabled="!isDialogTrainButton">确 定
                    </el-button>
                </div>
            </div>
        </el-dialog>


    </div>
</template>

<script>
    import pdf from 'vue-pdf';
    import 'quill/dist/quill.core.css';
    import 'quill/dist/quill.snow.css';
    import 'quill/dist/quill.bubble.css';
    import {quillEditor} from 'vue-quill-editor';

    const Ip = 'http://192.168.0.93:8889';
    export default {
        name: "",
        components: {pdf, quillEditor},
        data() {
            let _token = sessionStorage.getItem("tokenId");
            let menuId = sessionStorage.getItem('menuId');
            return {
                menuId: menuId,
                dataList: [],
                departments: [],
                allUserList: [],
                tokenId: _token,
                tableDialogHeightTabPane: {
                    height: (document.documentElement.clientHeight - 205) + 'px',
                    overflowY: 'auto'
                },
                applyDialogHeightTabPane: {
                    height: (document.documentElement.clientHeight - 270) + 'px',
                    overflowY: 'auto'
                },
                currentPage: 1,
                pagesize: 10,
                activeName: '1',
                activeApplyName: '1',
                activeTableName: 'first',

                //基本信息
                isTableDialog: false,
                dialogTableTitle: '',
                isRelevantDept: false,
                tableDialogData: {
                    essentialInfo: {
                        addFlag: "",
                        annexes: "",
                        approvalRemark: "",
                        changeTimes: "",
                        createTime: "",
                        drawingCode: "",
                        drawingCreater: "",
                        drawingCreater_name: "",
                        drawingIsPublish: "0",
                        drawingName: "",
                        drawingPath: "",
                        drawingPrice: "",
                        drawingPublishTime: "",
                        drawingPublisher: "",
                        drawingPublisher_name: "",
                        drawingRemark: "",
                        drawingType: "",
                        drawingType_desc: "",
                        drawingVersion: "",
                        id: "",
                        lastEditTime: "",
                        parentId: "",
                        relevantDept: [],
                        technicsRemark: "",
                        drawingNeedTrain: '',
                    },
                    drawingSrc: ''
                },
                tableDrawingId: '',
                appendixUrl: '/api/adscm/zltx/jyDrawingList/uploadAnnex/8/1',
                appendixData: [],

                //新增申请
                isApplyDialog: false,
                dialogApplyTitle: '',
                applyData: [],
                applyAppendixUrl: "/api/adscm/zltx/jyDrawingList/uploadAnnex/8/2",
                applyDialogData: {
                    essentialInfo: {
                        annexes: [],
                        approvalPerson: "",
                        approvalPersonName: "",
                        approvalRemark: "",
                        approvalResult: "",
                        approvalTime: "",
                        auditings: [],
                        drawingCode: "",
                        drawingId: "",
                        drawingIsPublish: "",
                        drawingName: "",
                        drawingNeedTrain: "",
                        drawingPrice: "",
                        drawingPublishTime: "",
                        drawingPublisher: "",
                        drawingPublisher_name: "",
                        drawingRemark: "",
                        drawingVersion: "",
                        id: "",
                        modifiedDrawingPath: "",
                        modifier: "",
                        modifierName: "",
                        modifyContent: "",
                        modifyReason: "",
                        modifyTime: "",
                        relevantDept: "",
                        technicsRemark: "",
                    },
                    drawingSrc: '',
                    instructionsSrc: ''
                },
                barsNumber: '',
                isSubmitExamine: false,
                isGoExamineButton: true,
                applyExamineList: {
                    aduditingDate: "",
                    auditingDept: "",
                    auditingDeptName: "",
                    auditingRemark: "",
                    auditingResult: "",
                    auditor: "",
                    auditorName: "",
                    drawingEditId: "",
                    id: "",
                },

                //回收与发放
                isGrantRecoveryDialog: false,
                dialogGrantRecoveryTitle: '',
                isDialogGrantRecoveryButton: true,
                dialogGrantRecoveryList: {
                    drawingEditId: "",
                    drawingId: "",
                    drawingVersion: "",
                    id: "",
                    issuNum: "",
                    issuRemark: "",
                    issuer: "",
                    issuerName: "",
                    receiveTime: "",
                    receiver: "",
                    receiverName: "",
                    recoverier: "",
                    recoverierName: "",
                    recoveryRemark: "",
                    recoveryTime: "",
                },
                tableGrantRecoveryData: [],

                //培训记录
                isTrainDialog: false,
                isDialogTrainButton: true,
                dialogTrainList: {
                    drawingEditId: "",
                    drawingId: "",
                    drawingVersion: "",
                    id: "",
                    trainHost: "",
                    trainHostName: "",
                    trainJoinor: "",
                    trainTime: "",
                },
                tableTrainData: [],

                //PDF
                drawingLoadedRatio: 0,
                drawingPage: 1,
                drawingNumPages: 0,
                drawingRotate: 0,
                instructionsLoadedRatio: 0,
                instructionsPage: 1,
                instructionsNumPages: 0,
                instructionsRotate: 0,

                drawingLoadedRatioApply: 0,
                drawingPageApply: 1,
                drawingNumPagesApply: 0,
                drawingRotateApply: 0,
                instructionsLoadedRatioApply: 0,
                instructionsPageApply: 1,
                instructionsNumPagesApply: 0,
                instructionsRotateApply: 0,
                tableDialogHeight: (document.documentElement.clientHeight - 210) + 'px',
                defaultProps: {
                    children: 'children',
                    label: 'drawingName',
                    id: 'id'
                },
                //权限
                jurisdiction: {
                    auditingEditInfo: true,
                    downloadAnnex: true,
                    downloadLastPdf: true,
                    downloadPdf: true,
                    insertDrawingEditInfo: true,
                    insertIssueRecovery: true,
                    printDrawingPdf: true,
                    recoveryDrawing: true,
                    releaseEditInfo: true,
                    selectDrawingBaseInfo: true,
                    selectDrawingEditInfo: true,
                    selectDrawingTrain: true,
                    selectDrawingTree: true,
                    selectIssueRecovery: true,
                    selectLastPdf: true,
                    updateDrawingList: true,
                    updateDrawingTrain: true,
                    uploadAnnex: true,
                    uploadDrawing: true,
                    viewDrawingPdf: true,
                }
            }
        },
        created() {
            this.getJurisdiction();
            this.getData();
            this.getDepartments();
            this.getUser();
        },
        mounted() {
            this.$refs.tree.style.height = (document.documentElement.clientHeight - 130) + 'px';
        },
        methods: {
            getJurisdiction() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/system/menu/getMenuAllSrc/' + _this.menuId + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        for (let i = 0; i < res.data.content.length; i++) {
                            let item = res.data.content[i];
                            _this.jurisdiction[item.component] = item.menuShow;
                        }

                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getDepartments() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/qsQsfileDept/selectAllDept?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.departments = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getUser() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/qsIssueRecyclingQsfile/queryUser/?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.allUserList = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("人员加载失败！请重新加载...");
                })
            },
            getData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/jyDrawingList/selectAll?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.dataList = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                    _this.$router.push({path: '/'});
                })
            },
            getDetailData(id) {
                let _this = this;
                _this.tableDialogData.drawingSrc = Ip + '/adscm/zltx/jyDrawingList/viewDrawingPdf/' + id + '/1?tokenId=' + _this.tokenId;
                this.$http({
                    url: '/api/adscm/zltx/jyDrawingList/selectById/' + id + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        let content = res.data.content;
                        _this.tableDialogData.essentialInfo = {
                            addFlag: content.addFlag ? content.addFlag : '',
                            annexes: content.annexes ? content.annexes : [],
                            approvalRemark: content.approvalRemark ? content.approvalRemark : '',
                            changeTimes: content.changeTimes ? content.changeTimes : '',
                            createTime: content.createTime ? _this.timestampToTime(content.createTime) : '',
                            drawingCode: content.drawingCode ? content.drawingCode : '',
                            drawingCreater: content.drawingCreater ? content.drawingCreater : '',
                            drawingCreater_name: content.drawingCreater_name ? content.drawingCreater_name : '',
                            drawingIsPublish: content.drawingIsPublish ? content.drawingIsPublish : '0',
                            drawingName: content.drawingName ? content.drawingName : '',
                            drawingPath: content.drawingPath ? content.drawingPath : '',
                            drawingPrice: content.drawingPrice ? content.drawingPrice : '',
                            drawingPublishTime: content.drawingPublishTime ? _this.timestampToTime(content.drawingPublishTime) : '',
                            drawingPublisher: content.drawingPublisher ? content.drawingPublisher : '',
                            drawingPublisher_name: content.drawingPublisher_name ? content.drawingPublisher_name : '',
                            drawingRemark: content.drawingRemark ? content.drawingRemark : '',
                            drawingType: content.drawingType ? content.drawingType : '',
                            drawingType_desc: content.drawingType_desc ? content.drawingType_desc : '',
                            drawingVersion: content.drawingVersion ? content.drawingVersion : '',
                            id: content.id ? content.id : '',
                            lastEditTime: content.lastEditTime ? _this.timestampToTime(content.lastEditTime) : '',
                            parentId: content.parentId ? content.parentId : '',
                            relevantDept: content.relevantDept ? content.relevantDept.split(',') : [],
                            technicsRemark: content.technicsRemark ? content.technicsRemark : '',
                            drawingNeedTrain: content.drawingNeedTrain ? content.drawingNeedTrain : '',
                        };

                        //部门字符串换成数组
                        let data = [];
                        for (let i = 0; i < _this.tableDialogData.essentialInfo.relevantDept.length; i++) {
                            let item = _this.tableDialogData.essentialInfo.relevantDept[i];
                            data.push(parseInt(item))
                        }
                        _this.tableDialogData.essentialInfo.relevantDept = data;
                        _this.isRelevantDept = _this.tableDialogData.essentialInfo.relevantDept.length === 0 ? false : true;

                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getApplyData(id) {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/jyDrawingEditInfo/selectByDrawingId/' + id + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.applyData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getRecoveryData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/jyDrawingIssueRecovery/selectIssueRecovery/' + _this.tableDrawingId + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.tableGrantRecoveryData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getTrainData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/jyDrawingTrain/selectDrawingTrain/' + _this.tableDrawingId + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.tableTrainData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            downloadAppendix(id, type) {
                if (type === "applyAppenddix") {
                    window.location.href = "/api/adscm/zltx/jyDrawingList/downloadFile/" + id;
                } else if (type === "tableNow") {
                    window.location.href = "/api/adscm/zltx/jyDrawingList/downloadPdf/" + this.tableDrawingId + "/1";
                } else if (type === "applyNow") {
                    window.location.href = "/api/adscm/zltx/jyDrawingList/downloadPdf/" + this.barsNumber + "/2";
                } else if (type === "applyLast") {
                    window.location.href = "/api/adscm/zltx/jyDrawingEditInfo/downLoadLastPdf/" + this.barsNumber;
                }
            },

            //基本信息
            submitUpload() {
                this.$refs.uploadDraw.submit();
                this.appendixUrl = '/api/adscm/zltx/jyDrawingList/uploadAnnex/' + this.tableDialogData.essentialInfo.id + '/1?tokenId=' + this.tokenId;
            },
            uploadDrawSuccess(response, file, fileList) {
                if (response.statusCode == 200) {
                    this.tableDialogData.essentialInfo.drawingPath = response.content;
                    this.$refs.uploadDraw.clearFiles();
                    this.$refs.uploadAppendix.submit();
                } else {
                    this.$message.error(response.desc)
                }
            },
            uploadAppendixSuccess(response, file, fileList) {
                if (response.statusCode == 200) {
                    this.$refs.uploadAppendix.clearFiles();
                    this.submitDetailData();
                } else {
                    this.$message.error(response.desc)
                }
            },
            uploadDrawError(response, file, fileList) {
                this.$message.error("图纸提交失败，请重新提交！");
            },
            uploadAppendixError(response, file, fileList) {
                this.$message.error("图纸提交失败，请重新提交！");
            },
            submitDetailData() {
                let _this = this;
                let param = _this.tableDialogData.essentialInfo;
                param.relevantDept = param.relevantDept.join(',');
                this.$http({
                    url: '/api/adscm/zltx/jyDrawingList/update?tokenId=' + _this.tokenId,
                    method: 'POST',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                    data: param
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isTableDialog = false;
                        _this.tableDialogData.drawingSrc = Ip + '/adscm/zltx/jyDrawingList/viewDrawingPdf/1/1?tokenId=' + _this.tokenId;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },

            openTableDialog(data) {
                let _this = this;
                _this.isTableDialog = true;
                _this.dialogTableTitle = data.drawingName;
                _this.tableDrawingId = data.id;

                _this.activeName = '1';
                _this.activeApplyName = '1';
                _this.activeTableName = 'first';
                _this.tableDialogData.drawingSrc = "";
                _this.drawingPage = 1;
                _this.instructionsPage = 1;

                //是否有权限访问基本信息
                if (_this.jurisdiction.selectDrawingBaseInfo) {
                    _this.getDetailData(data.id);
                }
                if (_this.jurisdiction.selectDrawingEditInfo) {
                    _this.getApplyData(data.id);
                }

            },

            //新增申请
            AddApplyDialog() {
                this.isApplyDialog = true;
                this.dialogApplyTitle = '新增申请';
                this.applyDialogData.essentialInfo = {
                    drawingCode: this.tableDialogData.essentialInfo.drawingCode,
                    drawingName: this.tableDialogData.essentialInfo.drawingName,
                    drawingVersion: this.tableDialogData.essentialInfo.drawingVersion,
                    drawingPrice: this.tableDialogData.essentialInfo.drawingPrice,
                    drawingRemark: this.tableDialogData.essentialInfo.drawingRemark,
                    technicsRemark: this.tableDialogData.essentialInfo.technicsRemark,
                    approvalPerson: '',
                    approvalRemark: '',
                    approvalResult: '',
                    approvalTime: '',
                    drawingId: this.tableDialogData.essentialInfo.id,
                    id: '',
                    modifiedDrawingPath: '',
                    modifiedInstructionsPath: '',
                    modifier: '',
                    modifyContent: "",
                    modifyReason: '',
                    modifyTime: '',

                    annexes: [],
                    approvalPersonName: "",
                    auditings: [],
                    drawingIsPublish: "0",
                    drawingNeedTrain: this.tableDialogData.essentialInfo.drawingNeedTrain,
                    drawingPublishTime: "",
                    drawingPublisher: "",
                    drawingPublisher_name: "",
                    modifierName: "",
                    relevantDept: this.tableDialogData.essentialInfo.relevantDept,
                };
            },
            submitEditDetailApplyData() {
                let _this = this;
                let data = {
                    approvalPerson: '0',
                    approvalRemark: _this.applyDialogData.essentialInfo.approvalRemark,
                    approvalResult: _this.applyDialogData.essentialInfo.approvalResult,
                    id: _this.applyDialogData.essentialInfo.id,
                };
                let param = new URLSearchParams();
                param.append('tokenId', _this.tokenId);
                param.append('JyDrawingEditInfoStr', JSON.stringify(data));
                this.$http({
                    url: '/api/adscm/zltx/jyDrawingEditInfo/auditingEditInfo?tokenId=' + _this.tokenId,
                    method: 'POST',
                    headers: {'deviceCode': 'A95ZEF1-47B5-AC90BF3'},
                    params: param,
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isApplyDialog = false;
                        if (_this.jurisdiction.selectDrawingEditInfo) {
                            _this.getApplyData(_this.applyDialogData.essentialInfo.drawingId);
                        }

                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            editApplyDialog(row) {
                this.isApplyDialog = true;
                this.isSubmitExamine = false;
                this.activeApplyName = '1';
                this.dialogApplyTitle = '审核申请';
                this.barsNumber = row.id;
                this.applyDialogData.essentialInfo = row;
                this.applyDialogData.essentialInfo.modifyTime = this.timestampToTime(row.modifyTime);
                this.applyDialogData.essentialInfo.drawingPublishTime = this.timestampToTime(row.drawingPublishTime);
                //部门字符串换成数组
                let relevantDept = row.relevantDept;
                if (relevantDept) {
                    if (typeof relevantDept === 'object') {
                        this.applyDialogData.essentialInfo.relevantDept = relevantDept;
                    } else if (typeof relevantDept === 'string') {
                        let data = [],
                            relevantDept1 = relevantDept.split(',');
                        for (let i = 0; i < relevantDept1.length; i++) {
                            data.push(parseInt(relevantDept1[i]))
                        }
                        this.applyDialogData.essentialInfo.relevantDept = data;
                    }
                } else {
                    this.applyDialogData.essentialInfo.relevantDept = [];
                }
                if (row.approvalResult == '5') {
                    this.applyDialogData.essentialInfo.drawingIsPublish = row.drawingIsPublish.toString();
                }
                this.applyDialogData.drawingSrc = Ip + '/adscm/zltx/jyDrawingList/viewDrawingPdf/' + row.id + '/3?tokenId=' + this.tokenId;
                this.applyDialogData.instructionsSrc = this.jurisdiction.selectLastPdf ? (Ip + '/adscm/zltx/jyDrawingEditInfo/selectLastPdf/' + row.id + '?tokenId=' + this.tokenId) : "";
            },
            submitApplyUpload() {
                if (this.dialogApplyTitle === '新增申请') {
                    this.$refs.uploadApplyDraw.submit();
                    this.applyAppendixUrl = '/api/adscm/zltx/jyDrawingList/uploadAnnex/' + this.tableDialogData.essentialInfo.id + '/2?tokenId=' + this.tokenId;
                } else if (this.dialogApplyTitle === '审核申请') {
                    this.submitEditDetailApplyData();
                }
            },
            uploadDrawApplySuccess(response, file, fileList) {
                if (response.statusCode == 200) {
                    this.applyDialogData.essentialInfo.modifiedDrawingPath = response.content;
                    this.$refs.uploadApplyDraw.clearFiles();
                    this.$refs.uploadApplyAppendix.submit();
                } else {
                    this.$message.error(response.desc)
                }
            },
            uploadApplyAppendixSuccess(response, file, fileList) {
                if (response.statusCode == 200) {
                    this.$refs.uploadApplyAppendix.clearFiles();
                    this.submitDetailApplyData();
                } else {
                    this.$message.error(response.desc)
                }
            },
            submitDetailApplyData() {
                let _this = this;
                let param = _this.applyDialogData.essentialInfo;
                param.relevantDept = param.relevantDept.join(",");
                this.$http({
                    url: '/api/adscm/zltx/jyDrawingEditInfo/insert?tokenId=' + _this.tokenId,
                    method: 'POST',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                    data: param
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isApplyDialog = false;
                        _this.applyDialogData.drawingSrc = Ip + '/adscm/zltx/jyDrawingList/viewDrawingPdf/1/3';
                        if (_this.jurisdiction.selectDrawingEditInfo) {
                            _this.getApplyData(_this.applyDialogData.essentialInfo.drawingId);
                        }

                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            //发布
            goRelease(row) {
                let _this = this;
                this.$confirm('确认发布吗?', '提示', {confirmButtonClass: 'el-button--warning'}).then(() => {
                    _this.$http({
                        url: '/api/adscm/zltx/jyDrawingEditInfo/releaseEditInfo/' + row.id + '?tokenId=' + _this.tokenId,
                        method: 'POST',
                        headers: {'X-Requested-With': 'XMLHttpRequest'}
                    }).then(function (res) {
                        if (res.data.statusCode == 200) {
                            if (_this.jurisdiction.selectDrawingEditInfo) {
                                _this.getApplyData(_this.applyDialogData.essentialInfo.drawingId);
                            }

                        } else {
                            _this.$message.error(res.data.desc);
                        }
                    }).catch(function (catchres) {
                        _this.$message.error("加载失败！请重新加载...");
                    })


                }).catch(() => {
                });

            },
            //审核
            goExamine(row) {
                this.isSubmitExamine = true;
                this.applyExamineList = {
                    aduditingDate: this.timestampToTime(row.aduditingDate),
                    auditingDept: row.auditingDept,
                    auditingDeptName: row.auditingDeptName,
                    auditingRemark: row.auditingRemark,
                    auditingResult: row.auditingResult,
                    auditor: row.auditor,
                    auditorName: row.auditorName,
                    drawingEditId: row.drawingEditId,
                    id: row.id,
                };
                this.isGoExamineButton = row.auditingResult !== '1' ? false : true;
            },
            submitExamine() {
                let _this = this;
                let param = {
                    drawingEditId: this.applyExamineList.drawingEditId,
                    auditingDept: this.applyExamineList.auditingDept,
                    auditingResult: this.applyExamineList.auditingResult,
                    auditingRemark: this.applyExamineList.auditingRemark,
                    id: this.applyExamineList.id,
                };
                this.$http({
                    url: '/api/adscm/zltx/jyDrawingEditInfo/auditingEditInfo?tokenId=' + _this.tokenId,
                    method: 'POST',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                    data: param
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isSubmitExamine = false;
                        _this.isApplyDialog = false;
                        if (_this.jurisdiction.selectDrawingEditInfo) {
                            _this.getApplyData(_this.applyDialogData.essentialInfo.drawingId);
                        }


                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },

            //发放与回收
            addGrant() {
                this.isGrantRecoveryDialog = true;
                this.dialogGrantRecoveryTitle = "发放";
                this.isDialogGrantRecoveryButton = true;
                this.dialogGrantRecoveryList = {
                    drawingEditId: "",
                    drawingId: this.tableDrawingId,
                    drawingVersion: "",
                    id: "",
                    issuNum: "",
                    issuRemark: "",
                    issuer: "",
                    issuerName: "",
                    receiveTime: "",
                    receiver: "",
                    receiverName: "",
                    recoverier: "",
                    recoverierName: "",
                    recoveryRemark: "",
                    recoveryTime: "",
                };
            },
            goRecovery(row) {
                this.isGrantRecoveryDialog = true;
                this.dialogGrantRecoveryTitle = "回收";
                this.isDialogGrantRecoveryButton = true;
                this.dialogGrantRecoveryList = {
                    drawingEditId: row.drawingEditId,
                    drawingId: row.drawingId,
                    drawingVersion: row.drawingVersion,
                    id: row.id,
                    issuNum: row.issuNum,
                    issuRemark: row.issuRemark,
                    issuer: row.issuer,
                    issuerName: row.issuerName,
                    receiveTime: row.receiveTime ? this.timestampToTime(row.receiveTime) : "",
                    receiver: row.receiver ? row.receiver : "",
                    receiverName: row.receiverName,
                    recoverier: row.recoverier,
                    recoverierName: row.recoverierName,
                    recoveryRemark: row.recoveryRemark,
                    recoveryTime: row.recoveryTime ? this.timestampToTime(row.recoveryTime) : "",
                };
            },
            submitRecovery() {
                let _this = this;
                _this.isDialogGrantRecoveryButton = false;
                let url;
                if (this.dialogGrantRecoveryTitle === "发放") {
                    url = "/api/adscm/zltx/jyDrawingIssueRecovery/insert?tokenId=" + _this.tokenId;
                } else if (this.dialogGrantRecoveryTitle === "回收") {
                    url = "/api/adscm/zltx/jyDrawingIssueRecovery/recoveryDrawing?tokenId=" + _this.tokenId;
                }
                this.$http({
                    url: url,
                    method: 'POST',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                    data: _this.dialogGrantRecoveryList
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isGrantRecoveryDialog = false;
                        if (_this.jurisdiction.selectIssueRecovery) {
                            _this.getRecoveryData();
                        }

                    } else {
                        _this.$message.error(res.data.desc);
                        _this.isDialogGrantRecoveryButton = false;
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                    _this.isDialogGrantRecoveryButton = false;
                })
            },

            //培训
            updateTrain(row) {
                this.isTrainDialog = true;
                this.isDialogTrainButton = true;
                this.dialogTrainList = {
                    drawingEditId: row.drawingEditId,
                    drawingId: row.drawingId,
                    drawingVersion: row.drawingVersion,
                    id: row.id,
                    trainHost: row.trainHost,
                    trainHostName: row.trainHostName,
                    trainJoinor: row.trainJoinor,
                    trainTime: row.trainTime,
                };

            },
            submitTrain() {
                let _this = this;
                _this.isDialogTrainButton = false;
                _this.dialogTrainList.trainTime = this.timestampToTime(_this.dialogTrainList.trainTime);
                this.$http({
                    url: "/api/adscm/zltx/jyDrawingTrain/update?tokenId=" + _this.tokenId,
                    method: 'POST',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                    data: _this.dialogTrainList
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isTrainDialog = false;
                        if (_this.jurisdiction.selectDrawingTrain) {
                            _this.getTrainData();
                        }

                    } else {
                        _this.$message.error(res.data.desc);
                        _this.isDialogTrainButton = false;
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                    _this.isDialogTrainButton = false;
                })
            },


            timestampToTime(timestamp) {
                let date = new Date(timestamp);
                let Y = date.getFullYear() + '-';
                let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                let D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + " ";
                let h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ":";
                let m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ":";
                return timestamp ? Y + M + D + h + m + '00' : '';
            },
            formatTimestampToTime(row, column, cellValue, index) {
                return cellValue ? this.timestampToTime(cellValue) : '';
            },
            formatResult(row, column, cellValue, index) {
                return cellValue == '1' ? '待审核' : (cellValue == '2' ? '审核中' : (cellValue == '3' ? '审核通过' : (cellValue == '4' ? '审核不通过' : (cellValue == '5' ? '已发布' : ''))));
            },
            formatIsResult(row, column, cellValue, index) {
                return cellValue ? (cellValue == 0 ? '不通过' : (cellValue == 1 ? '通过' : "")) : '待审核';
            },
            handleDialogClick(tab, event) {
                if (tab.name === '2') {
                    this.drawingRotate += 360;
                }
            },
            handleRecordDialogClick(tab, event) {
                if (tab.name === 'second') {
                    if (this.jurisdiction.selectIssueRecovery) {
                        this.getRecoveryData();
                    }
                } else if (tab.name === "third") {
                    if (this.jurisdiction.selectDrawingTrain) {
                        this.getTrainData();
                    }
                }
            },
            handleApplyDialogClick(tab, event) {
                if (tab.name === '2') {
                    this.instructionsRotateApply += 360;
                    this.drawingRotateApply += 360;
                }
            },
        }
    }

</script>

<style scoped>
    @import "equipment.css";
</style>
